package mest.service.cxj.impl;

import mest.VO.cxj.ProductOrderVO;
import mest.VO.cxj.ProductJobVO;
import mest.dao.cxj.ProductOrderDao;
import mest.entity.bom;
import mest.entity.product_order;
import mest.entity.save_file;
import mest.service.cxj.ProductOrderService;
import mest.service.system.DBService;
import mest.util.ObjectUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ProductOrderServiceImpl implements ProductOrderService {

    @Resource
    private ProductOrderDao productOrderDao;


    @Override
    public List<ProductOrderVO> selectAllProductOrder(Integer page, Integer limit, Integer checkStatus, String cfName, String planDo, String planFinish, String theirDb) {
        return productOrderDao.selectAllProductOrder((page - 1) * limit, limit, checkStatus, cfName, planDo, planFinish, theirDb);
    }

    @Override
    public Integer selectCountProductOrder(Integer checkStatus, String cfName, String planDo, String planFinish, String theirDb) {
        return productOrderDao.selectCountProductOrder(checkStatus, cfName, planDo, planFinish, theirDb);
    }

    @Override
    public int insertProductOrder(product_order po, String theirDb) {
        return productOrderDao.insertProductOrder(po, theirDb);
    }

    @Override
    public int updateProductOrder(product_order po, String theirDb) {
        return productOrderDao.updateProductOrder(po, theirDb);
    }

    @Override
    public boolean isExitId(product_order product_order) {
        boolean isExit = true;  //标识生产单ID是否存在，否则不能修改,默认存在为true
        if (!ObjectUtil.contains(product_order, "id")) {
            isExit = false;   //若检测出ID不存在，则为false
        }
        return isExit;
    }

    @Override
    public int updateProductOrderByStatus(Integer poId, String theirDb) {
        return productOrderDao.updateProductOrderByStatus(poId, theirDb);
    }

    @Override
    public List<ProductJobVO> selectProductInfo(Integer page, Integer limit, String commName, String theirDb) {
        return productOrderDao.selectProductInfo((page - 1) * limit, limit, commName, theirDb);
    }

    @Override
    public int selectProductInfoCount(String commName, String theirDb) {
        return productOrderDao.selectProductInfoCount(commName, theirDb);
    }

    @Override
    public List<save_file> selectBomInfo(Integer page, Integer limit, Integer bomId, String theirDb) {
        return productOrderDao.selectBomInfo((page - 1) * limit, limit, bomId, theirDb);
    }

    @Override
    public int selectBomInfoCount(Integer bomId, String theirDb) {
        return productOrderDao.selectBomInfoCount(bomId, theirDb);
    }
}
